<?php

namespace app\common\model;

use think\Model;

/**
 * 模型
 */
class OrderComment extends Model
{
    // 表名
    protected $name = 'order_comment';

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    const IS_ANONYMOUS = 1;  // 匿名
    const NOT_ANONYMOUS = 2; // 不腻名

    // 追加属性
    protected $append = [

    ];

    public function member()
    {
        return $this->belongsTo(Member::class, 'member_id');
    }

    public function commentImage()
    {
        return $this->hasMany(OrderCommentImage::class, 'order_comment_id');
    }

    public function getCreatetimeAttr($value)
    {
        return !empty($value) ? date('Y-m-d H:i',$value) : '';
    }

    public function getCommentAttr($value)
    {
        return !empty($value) ? $value : '';
    }

}
